/**
 * @author ChaP
 * @date 2019/05/23
 * @describe:
 */
package CodingTest.AC20190522;

import java.util.Arrays;
import java.util.Comparator;

public class findMinArrowShots {
    public int findMinArrowShots(int[][] points) {
        Arrays.sort(points, new Comparator<int[]>() {
            @Override
            public int compare(int[] o1, int[] o2) {
                return o1[0]-o2[0];
            }
        });
        int count = 1;
        int end = points[0][1];
        for(int[] point :points){
            if(point[0]>end){
                count++;
                end = point[1];
            }else{
                end = Math.min(end,point[1]);
            }
        }
        return count;
        }


    public static void main(String[] args) {
//        int[][] p = {{1,2},{3,4},{5,6},{7,8}};
        int [][]p = {{10,16},{2,8},{1,6},{7,12}};
        findMinArrowShots fs = new findMinArrowShots();
        System.out.println(fs.findMinArrowShots(p));
    }



}
